
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");
%>
<html>
<head>
    <title>万朗 2350300097</title>
</head>
<body>
<h1>这里是结算中心</h1>
<%
    // 获取用户姓名
    String username = request.getParameter("username");
    if (username == null || username.isEmpty()) {
        username = "张三"; // 默认值
    }

    // 获取用户选择的商品列表
    String[] selectedProducts = request.getParameterValues("products");
    if (selectedProducts == null || selectedProducts.length == 0) {
        selectedProducts = new String[]{"洗衣机", "冰箱", "电视机"}; // 默认值
    }

    // 计算商品数量
    int itemCount = selectedProducts.length;

    // 动态生成商品列表
    String productsList = String.join("、", selectedProducts);
%>

<p>客户<%= username %>，你一共买了<%= itemCount %>件商品，</p>
<p>分别是：<span class="product-name"><%= productsList %></span></p>
</body>
</html>
